﻿//===============================================================================
//	StringFactory.h
//	字符串工厂
//	静态工厂。所有std::string相关字符串从此处生成。申请使用完毕后，需要释放。
//===============================================================================

#pragma once

#include <mutex>
#include <memory>
#include <string>

#include <boost/pool/object_pool.hpp>

namespace string_factory
{
	//---------------------------------------------------------------------------
	std::string* CreateString(const char* str);
	bool FreeString(std::string* sp);

	//---------------------------------------------------------------------------
	class StringFactory
	{
	public:
		StringFactory(void);
		~StringFactory(void);

	public:
		std::string* CreateString(const char* str);
		bool FreeString(std::string* sp);
		void PurgeMemory(void);
		
	private:
		boost::object_pool<std::string> m_string_pool;
		std::recursive_mutex m_mutex;
	};
};